var flag = false;
function setflag() {
	flag = true;
}
function cancelflag() {
	flag = false;
}
// 点击打开提示框
function showtip(event,num) {
	// $("#main").html();
	main.style.allowTipHover = true;
	main.style.display = "block";
	// 鼠标定位
	event = event || window.event;
	var popup = main.style;
	var posX = event.clientX;
	var posY = event.clientY;
	
	if (posY > 2000) {
		popup.bottom = posY + 'px';
	} else {
		popup.top = posY + 'px';
	}
	if (posX > 2000) {
		popup.right = posX + 'px';
	} else {
		popup.left = posX + 'px';
	}

	// loadData()
	//设置echart中的data属性动态获取查询到的数据
	var data = setSeries(num);
	
	//loadData()
	var options = {
		series:[{
			type :'line',
			name : '温度',
			symbol : 'circle',
			label : {normal:{show : true,formatter :  '{c}℃'}},
			smooth:'true',
			data : data,
			markPoint : {data : [{type : 'max',label :{formatter:'{c}℃'},name : '当天最高温度' },
						{type : 'min',label :{formatter:'{c}℃'},name : '当天最低温度'}]},
			markLine : {data:[{type : 'average',name : '平均温度'}]}
		}]
	};
	tempPicChart.setOption(options);
}


// 关闭提示框
function hidetip() {
	if (!flag) {
		main.style.allowTipHover = true;
		main.style.display = "none";
	}
}


//动态获取24小时温度点数据并显示在echart
function setSeries(num){
	var resultDate = [];
	var tempVal = [];
	for(var i = 0;i<data.length;i++){
		resultDate.	push(data[i].temp);				
	}
	for(var i = 0;i<resultDate.length;i++){
			tempVal.push(resultDate[i]);
//		}
	}
	return tempVal[num];
}





$(function() {
	$("#main").mouseenter(setflag);
	$("#main").mouseleave(cancelflag);
});
//显示时间组件对话框
function show() {
	div1.style.display = "inline";// 设置层1显示
	div2.style.display = "inline";// 设置层2的显示
	// 弹出框随浏览器滚动而移动
	$(document).ready(function() {
//		var menuYloc = $("#div2").offset().top;
		$(window).scroll(function() {
			var offsetTop = $(window).scrollTop() + "px";
			$("#div2").css({
				top : offsetTop
			});
		});
	});
}


function buildORcommShow(){
	if (buildingUID != null) {
		closeShow();
		buildingUID = null;
	}else{
		communityTempShow();
	}
}

function closeTimeShow(){
	if (buildingUID != null) {
		div1.style.display = "none";
		div2.style.display = "none";
		buildingUID = null;
	}else{
		rMenu.css({
			"display" : "none"
		});
		div1.style.display = "none";
		div2.style.display = "none";
	}
}

// 关闭时间对话框显示
function closeShow() {
	recordDate = $("input[name = recordDate]").val();
	body.style.background = "url('temperature/images/user-img/123123.jpg') no-repeat scroll 120px 2px";
	body.style.backgroundSize = "1064px 755px";
	document.getElementById("container1").src = path
			+ "temperature/action/temperatureAction!queryTemperaturePointPage.do?projectUID="
			+ projectUID + "&communityUID=" + communityUID + "&buildingUID="
			+ buildingUID + "&recordDate=" + recordDate + "&date=" + new Date();
	div1.style.display = "none";
	div2.style.display = "none";
	$("#timeShow").html($("#recordDate").val());
}

function communityTempShow(){
	recordDate = $("input[name = recordDate]").val();
	body.style.backgroundSize = "1064px 755px";
	document.getElementById("container1").src = path + "temperature/action/temperatureAction!queryCommunityPointPage.do?projectUID="
			+ projectUID + "&communityUID=" + communityUID + "&buildingUID="
			+ buildingUID + "&recordDate=" + recordDate + "&filetreeNodeName="+ filetreeNodeName + "&projectNameString=" + projectNameString +"&date=" + new Date();
	document.getElementById("container1").style.margin = "0px 0px 0px 0px";
	document.getElementById("container1").style.width = "953px";
	rMenu.css({
		"display" : "none"
	});
	div1.style.display = "none";
	div2.style.display = "none";
}



// function myrefresh(){window.location.reload();} //设置页面自动刷新
// setTimeout('myrefresh()',1000 * 10); //指定10秒刷新一次 可根据需求更改时间
